package com.eims.sls_app.ui.adapter;

import java.util.List;

import bls.juejin.cn.R;

import com.eims.sls_app.dataaccess.LuckdrawBean;
import com.eims.sls_app.utils.AppTools;

import android.content.Context;
import android.text.Html;
import android.text.Spanned;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class LuckWinAdapter extends BaseAdapter {

	private List<LuckdrawBean> mBeans;
	private Context context;
	
	
	public LuckWinAdapter(List<LuckdrawBean> mBeans, Context context) {
		super();
		this.mBeans = mBeans;
		this.context = context;
	}

	@Override
	public int getCount() {
		
		return mBeans.size();
	}

	@Override
	public Object getItem(int position) {
		
		return position;
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHoloder holoder = null;
		if (convertView==null) {
			holoder = new ViewHoloder();
			convertView = LayoutInflater.from(context).inflate(
					R.layout.draw_item_not, null);
			holoder.tv_money = (TextView) convertView.findViewById(R.id.tv_money);
			holoder.tv_time = (TextView) convertView.findViewById(R.id.tv_datatime);
			convertView.setTag(holoder);
		}else {
			holoder = (ViewHoloder) convertView.getTag();
		}
		if (mBeans.get(position).getMoney()==0.0) {
			Spanned text = Html.fromHtml(AppTools.changeStringColor("#D13D4B", "未中奖"));
			holoder.tv_money.setText(text);
		}else {
			Spanned text = Html.fromHtml(AppTools.changeStringColor("#D13D4B", mBeans.get(position).getMoney()+"元"));
			holoder.tv_money.setText(text);
		}
		
		
		holoder.tv_time.setText(mBeans.get(position).getDatetime());
		
		return convertView;
	}
	
	public class ViewHoloder {
		TextView tv_money;
		TextView tv_time;
	}

}
